<?php 
if(!defined('DREAMSCAPE')){die('Sorry, but this file cannot be directly viewed.');} 
/*   Preferences   //-------*/
add_admin_menu(L_ADMIN_PREFS,array('<a href="?cat=admin&amp;sub=prefs">'.L_MENU_EDIT.'</a>'),'preferences');

if($admin_sub !== 'prefs'){return;}
add_breadcrumb(L_PREFS_TITLE);
add_title(L_PREFS_TITLE);
ozone_action('admin_page', 'prefs_content');
function prefs_content(){
	global $output, $currencysymbols , $themesdir;
		 if (is_posting(L_BUTTON_UPDATE)) {
								manageOptions("submit,rettimeformat,retdateformat,utctime,resettime");
								$use_clean_urls = getOption('use_clean_urls');
								if($use_clean_urls == 1 && CAN_REWRITE){
								$the_ht = HOMEPATH.'/.htaccess';
								$yoursite = checkTrailingSlash(getOption('yoursite'));
								$index_file = getOption('index_file');
								if((!file_exists($the_ht) && is_writable(HOMEPATH)) || is_writable($the_ht)){
									$site_root = parse_url($yoursite);
									$site_root = checkTrailingSlash($site_root['path']);
									$index_file = isset($index_file) && !empty($index_file) ? $site_root.$index_file : $site_root.'index.php';
									$rewrite_rules = array(
										'<IfModule mod_rewrite.c>',
										'RewriteEngine On',
										'RewriteBase '.$site_root,
										'RewriteCond %{REQUEST_FILENAME} !-f',
										'RewriteCond %{REQUEST_FILENAME} !-d',
										'RewriteRule . '.$index_file.' [L]',
										'</IfModule>'
									);
									
									insert_between(HOMEPATH.'/.htaccess', 'dreamscape rewrite ninja madness', $rewrite_rules);
								}
								}
										 applyOzoneAction('manage_options');
										 }
								$option = getAllOptions();	 			
		?>
<?php echo $output ;?>

<div class="stretchContainer">
  

<!--
/*
============================================================
General Settings
============================================================
*/ 
-->
  <h3 class="stretchToggle" title="general"> <a href="#general"><span><?php echo L_PREFS_HDR_GENERAL ?></span></a> </h3>
  <div class="stretch" id="general">
    

<!-- /*   Your Name   //===============================*/ -->
    <label for="yourname"><?php echo L_PREFS_YOUR_NAME ?></label>
    <input name="yourname" type="text" class="formfields" id="yourname" value="<?php echo $option->yourname; ?>" size="40" />
	<?php tooltip(L_PREFS_YOUR_NAME, L_PREFS_YOUR_NAME_HELP); ?>
    
<!-- /*   Admin Email   //===============================*/ -->
    <label for="adminemail"><?php echo L_PREFS_ADMIN_EMAIL ?></label>
    <input name="adminemail" type="text" class="formfields" id="adminemail" value="<?php echo $option->adminemail; ?>" size="40" />
	<?php tooltip(L_PREFS_ADMIN_EMAIL, L_PREFS_ADMIN_EMAIL_HELP); ?> 
    
    

<!-- /*   Site Name   //===============================*/ -->
    <label for="sitename"><?php echo L_PREFS_SITE_NAME ?></label>
    <input name="sitename" type="text" class="formfields" id="sitename" value="<?php echo $option->sitename; ?>" size="40" /> 
    <?php tooltip(L_PREFS_SITE_NAME, L_PREFS_SITE_NAME_HELP); ?> 
    

<!-- /*   Site Description   //===============================*/ -->
    <label for="sitedescr"><?php echo L_PREFS_SITE_DESCRIPTION ?></label>
    <textarea name="sitedescr" cols="40" class="formfields" id="sitedescr"><?php echo $option->sitedescr; ?></textarea>
	<?php tooltip(L_PREFS_SITE_DESCRIPTION, L_PREFS_SITE_DESCRIPTION_HELP); ?> 
    

<!-- /*   Your Site URL   //===============================*/ -->
    <label for="yoursite"><?php echo L_PREFS_SITE_URL ?> </label>
    <input name="yoursite" type="text" class="formfields" id="yoursite" value="<?php echo checkTrailingSlash($option->yoursite); ?>" size="40" /> 
	<?php tooltip(L_PREFS_SITE_URL, array(L_PREFS_SITE_URL_HELP, checkTrailingSlash($_SERVER['HTTP_HOST']))); ?> 
    
	<?php applyOzoneAction('preferences_general_menu'); ?>
<!-- // -->
  </div>
  

<!--
/*
============================================================
Time Settings
============================================================
*/ 
-->
  <h3 class="stretchToggle" title="timeSettings"><a href="#timeSettings"><span><?php echo L_PREFS_HDR_TIME ?></span></a></h3>
  <div class="stretch" id="timeSettings">
    

<!-- /*   Current Server Time   //===============================*/ -->
    <label for="utctime"><?php echo L_PREFS_TIME_SERVER ?> </label>
    <input name="utctime" type="text" class="formatSettings" id="utctime" value="<?php echo date('F d, Y g:i:s a');?>" size="40" />
	<?php tooltip(L_PREFS_TIME_SERVER, L_PREFS_TIME_SERVER_HELP); ?>
    

<!-- /*   Local Timezone Offset   //===============================*/ -->
    <label for="timeoffset"><?php echo L_PREFS_TIME_TZ_OFFSET ?></label>
    <input name="timeoffset" type="text" class="formfields" id="timeoffset" value="<?php echo isset($option->timeoffset) ? $option->timeoffset : '';?>" size="10" />
	<?php tooltip(L_PREFS_TIME_TZ_OFFSET, L_PREFS_TIME_TZ_OFFSET_HELP); ?>
    

<!-- /*   Date Format   //===============================*/ -->
    <label for="dateformat"><?php echo L_PREFS_TIME_FORMAT_DATE ?> </label>
    <input name="dateformat" type="text" class="formfields" id="dateformat" value="<?php echo $option->dateformat; ?>" size="40" />
	<br />
    

<!-- /*   Current Date Format   //===============================*/ -->
    <label for="retdateformat" class="formatSettingsL"><?php echo L_PREFS_TIME_CURR_FORMAT_DATE ?></label>
    <input name="retdateformat" type="text" class="formatSettings" id="retdateformat" value="" size="40" />
	<?php tooltip(L_PREFS_TIME_CURR_FORMAT_DATE, array(L_PREFS_TIME_CURR_FORMAT_DATE_HELP, date($option->dateformat))); ?>
    

<!-- /*   Time Format   //===============================*/ -->
    <label for="timeformat"><?php echo L_PREFS_TIME_FORMAT_TIME ?></label>
    <input name="timeformat" type="text" class="formfields" id="timeformat" value="<?php echo $option->timeformat; ?>" size="40" />
    <br />
    

<!-- /*   Current Time Format   //===============================*/ -->
    <label for="rettimeformat" class="formatSettingsL"><?php echo L_PREFS_TIME_CURR_FORMAT_TIME ?></label>
    <input name="rettimeformat" type="text" class="formatSettings" id="rettimeformat" value="" size="40" />
	<?php tooltip(L_PREFS_TIME_CURR_FORMAT_TIME, array(L_PREFS_TIME_CURR_FORMAT_DATE_HELP, date($option->timeformat))); ?>
    
	<?php applyOzoneAction('preferences_time_menu'); ?>
<!-- // -->
  </div>
  

<!--
/*
============================================================
Theme/Appearance Settings
============================================================
*/ 
-->
  <h3 class="stretchToggle" title="appearanceSettings"><a href="#appearanceSettings"><span><?php echo L_PREFS_HDR_APPEARANCE ?></span></a></h3>
  <div class="stretch" id="appearanceSettings">
    

<!-- /*   Start Category   //===============================*/ -->
    <label for="startcategory"><?php echo L_PREFS_APP_START_CATEGORY ?></label>
    <select name="startcategory" id="startcategory" class="formfields">
      <?php 
$startcategory = $option->startcategory;
$selected = ($startcategory == 'ALL') ? ' selected="selected"' : '';
echo '<option'.$selected.' value="ALL">All categories</option>';
$d2 = mysql_query("
SELECT * FROM ".PREFIX."sections 
WHERE pid = 0");
while($d3 = mysql_fetch_array($d2)){
$d4 = mysql_query("
SELECT * FROM ".PREFIX."sections 
WHERE pid = $d3[id]");	
if($d3['cat_type'] == 'pages'){
	echo '<optgroup label="&mdash;User Created Pages"></optgroup>';
	get_page_dropdown(0,0,0,true, $startcategory);
	continue;
	}
$selected = ($d3['id'] == $startcategory) ? ' selected="selected"' : '';
?>
      <option<?php echo $selected ?> value="<?php echo $d3['id'] ?>"><?php echo ucwords($d3['sectionname']) ?></option>
      <?php
	while($d5 = mysql_fetch_array($d4)){
	$selected = ($d5['id'] == $startcategory) ? ' selected="selected"' : '';
	?>
      <option<?php echo $selected ?> value="<?php echo $d5['id'] ?>">&mdash;<?php echo $d5['sectionname'] ?></option>
      <?php
	}
}

?>
    </select>
	<?php tooltip(L_PREFS_APP_START_CATEGORY, L_PREFS_APP_START_CATEGORY_HELP); ?>
	

<!-- /*   How many per page?   //===============================*/ -->
    <label for="howmany"><?php echo L_PREFS_APP_HOW_MANY ?></label>
    <input type="text" name="howmany" value="<?php echo $option->howmany; ?>" class="formfields" id="howmany" />
	<?php tooltip(L_PREFS_APP_HOW_MANY, L_PREFS_APP_HOW_MANY_HELP); ?>
    

<!-- /*   How many per edit page?   //===============================*/ -->
    <label for="howmany_edit"><?php echo L_PREFS_APP_HOW_MANY_EDIT ?></label>
    <input type="text" name="howmany_edit" value="<?php echo $option->howmany_edit; ?>" class="formfields" id="howmany_edit" />
	<?php tooltip(L_PREFS_APP_HOW_MANY_EDIT, array(L_PREFS_APP_HOW_MANY_EDIT_HELP, CMS_NAME)); ?>
    

<!-- /*   Sort your categories by   //===============================*/ -->
    <label for="sortcats"><?php echo L_PREFS_APP_SORT_CATS ?></label>
    <select id="sortcats" class="formfields" name="sortcats">
<?php 
$items = new Dreamscape('items');
foreach($items->Fields as $ind => $val){
?>
      <?php 
switch($val){
case 'id':
$sorttag = L_SORT_BY_ID;
break;
case 'title':
$sorttag = L_SORT_BY_TITLE;
break;
case 'aid':
$sorttag = L_SORT_BY_USER;
break;
case 'created':
$sorttag = L_SORT_BY_DATE;
break;
case 'order_rank':
$sorttag = L_SORT_BY_USER_RANK;
break;
default:
$sorttag = '';
break;
}
$selected = ($val == $option->sortcats) ? ' selected="selected"' : '';
?>
      <?php echo !empty($sorttag) ? '<option value="'.$val.'"'.$selected.'>'.$sorttag.'</option>' : '' ?>
      <?php
}
?>
    </select>
	<?php tooltip(L_PREFS_APP_SORT_CATS, array(L_PREFS_APP_SORT_CATS_HELP, CMS_NAME)); ?>
    

<!-- /*   Sort Direction   //===============================*/ -->
    <label for="sortdirection"><?php echo L_PREFS_APP_SORT_DIR ?></label>
    <select id="sortdirection" class="formfields" name="sortdirection">
      <option value="ASC"<?php echo $option->sortdirection == 'ASC' ? ' selected="selected"' : '' ?>><?php echo L_SORT_BY_ASC ?></option>
      <option value="DESC"<?php echo $option->sortdirection == 'DESC' ? ' selected="selected"' : '' ?>><?php echo L_SORT_BY_DESC ?></option>
    </select>
	<?php tooltip(L_PREFS_APP_SORT_DIR, array(L_PREFS_APP_SORT_DIR_HELP, array(CMS_NAME,CMS_NAME))); ?>
    

<!-- /*   Default Thumbnail Size   //===============================*/ -->
    <label for="thumbsize"><?php echo L_PREFS_APP_THUMB_SIZE ?></label>
    <input type="text" name="thumbsize" value="<?php echo $option->thumbsize; ?>" class="formfields" id="thumbsize" />
	<?php tooltip(L_PREFS_APP_THUMB_SIZE, L_PREFS_APP_THUMB_SIZE_HELP); ?>

<!-- /*   Show smilies in comments?   //===============================*/ -->
    <label for="commentsmilies"><?php echo L_PREFS_APP_SMILIES_COMMENTS ?></label>
    <input type="hidden" value="0" name="commentsmilies" />
    <input type="checkbox" name="commentsmilies" value="1"<?php echo $option->commentsmilies == 1 ? ' checked="checked"' : '';?> class="cBox" id="commentsmilies" />
	<?php tooltip(L_PREFS_APP_SMILIES_COMMENTS, L_PREFS_APP_SMILIES_COMMENTS_HELP); ?>
    

<!-- /*   Select Theme   //===============================*/ -->
    <label for="theme"><?php echo L_PREFS_APP_THEME ?></label>
    <select name="theme" id="theme" class="formfields">
      <?php 
$theme = $option->theme;
if (is_dir($themesdir)) {
   if ($dh = opendir($themesdir)) {
   
       while (($file = readdir($dh)) !== false) {
          if(is_dir($themesdir."/".$file) && $file != '.' && $file != '..'){
		  	echo ($file == $theme) ? '<option selected="selected">'.$file.'</option>' : '<option>'.$file.'</option>';
		  }
		   
       }
       closedir($dh);
   }
}
?>
    </select>
	<?php tooltip(L_PREFS_APP_THEME,L_PREFS_APP_THEME_HELP); ?>

    <?php if(CAN_REWRITE){ ?>
<!-- /*   Clean URLS   //===============================*/ -->
    <label for="use_clean_urls"><?php echo L_PREFS_APP_CLEAN_URLS ?></label>
    <input type="hidden" name="use_clean_urls" value="0" />
    <input type="checkbox" id="use_clean_urls" name="use_clean_urls" value="1" <?php echo isset($option->use_clean_urls) && $option->use_clean_urls == 1 ? 'checked="checked"' : ''; ?> />
	<?php tooltip(L_PREFS_APP_CLEAN_URLS, array(L_PREFS_APP_CLEAN_URLS_HELP, array($option->yoursite,INDEX_PAGE,$option->yoursite))); ?>
    <?php } ?>

<!-- /*   Index file renaming   //===============================*/ -->
    <label for="index_file"><?php echo L_PREFS_APP_INDEX_FILE ?></label>
    <input type="text" id="index_file" name="index_file" value="<?php echo $option->index_file ?>" />
	<?php tooltip(L_PREFS_APP_INDEX_FILE, L_PREFS_APP_INDEX_FILE_HELP); ?>
    
	<?php applyOzoneAction('preferences_theme_menu'); ?>
<!-- // -->
  </div>
  

<!--
/*
============================================================
Paypal Settings
============================================================
*/ 
-->
  <h3 class="stretchToggle" title="paypalSettings"><a href="#paypalSettings"><span><?php echo L_PREFS_HDR_PAYPAL ?></span></a></h3>
  <div class="stretch" id="paypalSettings">
    

<!-- /*   Paypal E-mail   //===============================*/ -->
    <label for="paypal_email"><?php echo L_PREFS_PP_EMAIL ?></label>
    <input name="paypal_email" type="text" class="infields" id="paypal_email" value="<?php echo $option->paypal_email;?>" size="40" />
	<?php tooltip(L_PREFS_PP_EMAIL, L_PREFS_PP_EMAIL_HELP); ?>
    

<!-- /*   Currency Type   //===============================*/ -->
    <label for="paypal_currency_code"><?php echo L_PREFS_PP_CURRENCY_CODE ?></label>
    <select name="paypal_currency_code" id="paypal_currency_code" class="infields">
      <?php
foreach($currencysymbols as $ind => $val){
?>
      <option value="<?php echo $ind ?>"<?php echo $ind == $option->paypal_currency_code ? 'selected="selected"' : ''; ?>><?php echo $ind ?> (<?php echo $val ?>)</option>
      <?php
}
 ?>
    </select>
	<?php tooltip(L_PREFS_PP_CURRENCY_CODE, L_PREFS_PP_CURRENCY_CODE_HELP); ?>
    

<!-- /*   Paypal Logo   //===============================*/ -->
    <label for="paypal_logo"><?php echo L_PREFS_PP_LOGO_URL ?></label>
    <input name="paypal_logo" type="text" class="infields" id="paypal_logo" value="<?php echo $option->paypal_logo;?>" size="40" />
	<?php tooltip(L_PREFS_PP_LOGO_URL, L_PREFS_PP_LOGO_URL_HELP); ?>
    

<!-- /*   Shipping Cost   //===============================*/ -->
    <label for="paypal_shipping"><?php echo L_PREFS_PP_SHIPPING ?></label>
    <input name="paypal_shipping" type="text" class="infields" id="paypal_shipping" value="<?php echo $option->paypal_shipping;?>" size="40" />
	<?php tooltip(L_PREFS_PP_SHIPPING, L_PREFS_PP_SHIPPING_HELP); ?>
    

<!-- /*   Shipping cost (multiple items)   //===============================*/ -->
    <label for="paypal_shipping2"><?php echo L_PREFS_PP_SHIPPING2 ?></label>
    <input name="paypal_shipping2" type="text" class="infields" id="paypal_shipping2" value="<?php echo $option->paypal_shipping2;?>" size="40" />
	<?php tooltip(L_PREFS_PP_SHIPPING2, L_PREFS_PP_SHIPPING2_HELP); ?>
    

<!-- /*   Item Tax   //===============================*/ -->
    <label for="paypal_tax"><?php echo L_PREFS_PP_TAX ?></label>
    <input name="paypal_tax" type="text" class="infields" id="paypal_tax" value="<?php echo $option->paypal_tax;?>" size="40" />
	<?php tooltip(L_PREFS_PP_TAX, L_PREFS_PP_TAX_HELP); ?>
    

<!-- /*   Handling Cost   //===============================*/ -->
    <label for="paypal_handling_cart"><?php echo L_PREFS_PP_HANDLING ?></label>
    <input name="paypal_handling_cart" type="text" class="infields" id="paypal_handling_cart" value="<?php echo $option->paypal_handling_cart;?>" size="40" />
	<?php tooltip(L_PREFS_PP_HANDLING, L_PREFS_PP_HANDLING_HELP); ?>
    
	<?php applyOzoneAction('preferences_paypal_menu'); ?>
<!-- // -->
  </div>

<!--
/*
============================================================
Language Settings
============================================================
*/ 
-->

  <h3 class="stretchToggle" title="languageSettings"><a href="#languageSettings"><span><?php echo L_PREFS_HDR_LANGUAGE ?></span></a></h3>
  <div class="stretch" id="languageSettings">
    
<!-- /*   Choose a language   //===============================*/ -->
    <label for="language"><?php echo L_PREFS_LANGUAGE ?></label>
	<?php
	  $language_files = getFiles(LEXICON, 'files');
	  //debug($language_files); ?>
	  <select name="language" id="language" class="infields"> 
      <?php
	  $language_files = getFiles(LEXICON, 'files');
foreach($language_files as $ind => $val){
$ext = strrchr($val, '.');
$file_name = remExtension($val);
if($ext != '.php' || $file_name == 'index'){continue;}
$lang_info = language_info(LEXICON.$val);
?>
      <option value="<?php echo $file_name ?>"<?php echo $file_name == $option->language ? 'selected="selected"' : ''; ?>><?php echo $lang_info->Language ?> (<?php printf(L_PREFS_LANGUAGE_TRANSLATED_BY, $lang_info->Translator); ?>)</option>
      <?php
}
 ?>
    </select>
	<?php tooltip(L_PREFS_LANGUAGE, sprintf(L_PREFS_LANGUAGE_HELP, CMS_NAME)); ?>
    
	<?php applyOzoneAction('preferences_language_menu'); ?>
<!-- // -->
  </div>
  <!--
/*
============================================================
User/Comment Filtering Settings
============================================================
*/ 
-->

  <h3 class="stretchToggle" title="commentSettings"><a href="#commentSettings"><span><?php echo L_PREFS_HDR_COMMENTS ?></span></a></h3>
  <div class="stretch" id="commentSettings">
    
<!-- /*   Moderate all comments   //===============================*/ -->
    <label for="moderate_comments"><?php echo L_PREFS_USER_MODERATE ?></label>
    <input type="hidden" name="moderate_comments" value="0" />
    <input name="moderate_comments"<?php echo isset($option->moderate_comments) && $option->moderate_comments == 1 ? 'checked="checked"' : ''; ?> type="checkbox" class="formfields" id="moderate_comments" value="1" size="40" />
	<?php tooltip(L_PREFS_USER_MODERATE, L_PREFS_USER_MODERATE_HELP); ?>
    

<!-- /*   Flood Control Delay   //==============================*/ -->
    <label for="floodcontrol"><?php echo L_PREFS_USER_FLOODING ?></label>
    <input name="floodcontrol" type="text" class="formfields" id="floodcontrol" value="<?php echo $option->floodcontrol;?>" size="40" />
	<?php tooltip(L_PREFS_USER_FLOODING, L_PREFS_USER_FLOODING_HELP); ?>
    

<!-- /*   Banned Words   //===============================*/ -->
    <label for="bannedwords"><?php echo L_PREFS_USER_BANNED_WORDS ?></label>
    <textarea rows="" cols="" class="formfields" name="bannedwords" id="bannedwords"><?php echo $option->bannedwords; ?></textarea>
	<?php tooltip(L_PREFS_USER_BANNED_WORDS, L_PREFS_USER_BANNED_WORDS_HELP); ?><br />


<!-- /*   Banned IPs   //===============================*/ -->
    <label for="bannedips"><?php echo L_PREFS_USER_BANNED_IPS ?></label>
    <textarea rows="" cols="" class="formfields" name="bannedips" id="bannedips"><?php echo $option->bannedips; ?></textarea>
	<?php tooltip(L_PREFS_USER_BANNED_IPS, L_PREFS_USER_BANNED_IPS_HELP); ?>
    
	<?php applyOzoneAction('preferences_filter_menu'); ?>
<!-- // -->
  </div>
  <?php applyOzoneAction('preferences_menu'); ?>
</div>
<label for="edit"></label>
<input type="submit" name="submit" class="buttons" value="<?php echo L_BUTTON_UPDATE ?>" />
<br />
<?php 
}
?>